{% extends 'base_main.html' %}
{% block title %}
<title>目录文章</title>
{% endblock %}

{% block content%}
{{block.super}}
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-lg-10 col-md-offset-2 main" id="main">
    <form action="/Article/checkAll" method="post">
        <h1 class="page-header">操作</h1>
        <ol class="breadcrumb">
            <li><a href="{% url 'myblog:add_article' %}?c_id={{art_list.0.id}}">增加文章</a></li>
        </ol>
        <h1 class="page-header">管理 <span class="badge">{{art_list.1.0}}</span></h1>
        <div class="table-responsive">
            <table class="table table-striped table-hover">
                <thead>
                <tr>
                    <th><span class="glyphicon glyphicon-th-large"></span> <span class="visible-lg">选择</span>
                    </th>
                    <th><span class="glyphicon glyphicon-file"></span> <span class="visible-lg">标题</span></th>
                    <th><span class="glyphicon glyphicon-list"></span> <span class="visible-lg">父栏目</span></th>
                    <th><span class="glyphicon glyphicon-list"></span> <span class="visible-lg">栏目</span></th>
                    <th class="hidden-sm"><span class="glyphicon glyphicon-tag"></span> <span
                            class="visible-lg">标签</span></th>
                    <th class="hidden-sm"><span class="glyphicon glyphicon-comment"></span> <span
                            class="visible-lg">评论</span></th>
                    <th><span class="glyphicon glyphicon-time"></span> <span class="visible-lg">发布日期</span></th>
                    <th><span class="glyphicon glyphicon-time"></span> <span class="visible-lg">最后更新</span></th>
                </tr>
                </thead>
                <tbody>
                {% for a in art_list.1.1 %}
                <tr>
                    <td><input type="checkbox" class="input-control" name="checkbox[]" value=""/></td>
                    <td class="article-title">{{a.title}}</td>
                    <td>{% if a.col.columns %}{{a.col.columns.name}}{% else %}无{% endif %}</td>
                    <td>{{a.col.name}}</td>
                    <td class="hidden-sm">{% for l in a.lab.all %}{% if forloop.last %}{{l.name}}{% else %}{{l.name}},{% endif %}{% endfor %}</td>
                    <td class="hidden-sm">{{a.com.count}}</td>
                    <td>{{a.add_time|date:'Y-m-d H:i:s'}}</td>
                    <td>{{a.update_time|date:'Y-m-d H:i:s'}}</td>
                </tr>
                {% endfor %}
                </tbody>
            </table>
        </div>
        <footer class="message_footer">
            <nav>
                <div class="btn-toolbar operation" role="toolbar">
                    <div class="btn-group" role="group"><a class="btn btn-default" onClick="select()">全选</a> <a
                            class="btn btn-default" onClick="reverse()">反选</a> <a class="btn btn-default"
                                                                                  onClick="noselect()">不选</a>
                    </div>
                    <div class="btn-group" role="group">
                        <button type="submit" class="btn btn-default" data-toggle="tooltip" data-placement="bottom"
                                title="删除全部选中" name="checkbox_delete">删除
                        </button>
                    </div>
                </div>
                <ul class="pagination pagenav">
                    <li {% if not art_list.has_previous %} class="disabled" {% endif %}><a href="{% if art_list.has_previous %}{% url 'myblog:article' %}?page={{art_list.previous_page_number}}{% else %}javascript:void(0){% endif %}" aria-label="Previous"> <span aria-hidden="true">&laquo;</span> </a></li>
                    {% for pg in art_list.paginator.page_range %}
                    <li {% if pg == art_list.number %} class="active" {% endif %}><a href="{% url 'myblog:article' %}?page={{pg}}">{{pg}}</a></li>
                    {% endfor %}
                    <li {% if not art_list.has_next %} class="disabled" {% endif %}><a href="{% if art_list.has_next %}{% url 'myblog:article' %}?page={{art_list.next_page_number}} {% else %}javascript:void(0){% endif %}" aria-label="Next"> <span aria-hidden="true">&raquo;</span> </a></li>
                </ul>
            </nav>
        </footer>
    </form>
</div>
{% endblock %}
{% block js%}
{{block.super}}
<script>
//是否确认删除
$(function(){
	$("#main table tbody tr td a").click(function(){
		var name = $(this);
		var id = name.attr("rel"); //对应id
		if (event.srcElement.outerText == "删除")
		{
			if(window.confirm("此操作不可逆，是否确认？"))
			{
				$.ajax({
					type: "POST",
					url: "/myblog/delete_article/",
					data: {
					    'id':id
					},
					cache: false, //不缓存此页面
					success: function (data) {
						window.location.reload();
					}
				});
			};
		};
	});
});
</script>
{% endblock %}

